package org.yu.team2023.flashdays.registries;

import com.google.common.collect.Multimap;
import lombok.NonNull;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;


public class SimpleItemTagProvider extends ItemTagsProvider {
    protected final Multimap<Supplier<? extends Item>, TagKey<Item>> itemTags;
    protected final List<TagKey<Block>> blockTagsCopyList;
    public SimpleItemTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> completableFuture, CompletableFuture<TagLookup<Block>> blockLookup, String modId, @NonNull ExistingFileHelper existingFileHelper, Multimap<Supplier<? extends Item>, TagKey<Item>> itemTags, List<TagKey<Block>> blockTagsCopyList) {
        super(output, completableFuture, blockLookup, modId, existingFileHelper);
        this.itemTags = itemTags;
        this.blockTagsCopyList = blockTagsCopyList;
    }

    @Override
    protected void addTags(@NotNull HolderLookup.Provider provider) {
        itemTags.forEach((supplier, tagKey) -> tag(tagKey).add(supplier.get()));
        blockTagsCopyList.forEach(blockTagKey -> SimpleItemTagProvider.this.copy(blockTagKey,TagKey.create(ForgeRegistries.ITEMS.getRegistryKey(),blockTagKey.location())));
    }

}
